/* eslint-disable */
// @ts-ignore
import { queryOptions, useMutation } from '@tanstack/vue-query';
import type { DefaultError } from '@tanstack/vue-query';
import request from '@/utils/request';
import { CustomRequestOptions } from '@/interceptors/request';

import * as apis from './yonghumenpiaodingdan';
import * as API from './types';

/** 下单 POST /tourism/client/c/order/add */
export function useAddUsingPost1Mutation(options?: {
  onSuccess?: (value?: API.CommonResultMapStringObject_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.addUsingPost1,
    onSuccess(data: API.CommonResultMapStringObject_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 对订单评论 POST /tourism/client/c/order/addcomment */
export function useAddCommentUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.addCommentUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 获取订单详情 GET /tourism/client/c/order/detail */
export function detailUsingGet1QueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.detailUsingGET1Params;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.detailUsingGet1(queryKey[1] as typeof options);
    },
    queryKey: ['detailUsingGet1', options],
  });
}

/** 分销订单列表 查询当前登录用户作为分销用户邀请到的用户为其带来的分销订单列表及统计信息。返回数据包含：1. orders: 订单分页信息，每个订单包含commission字段表示当前用户的分佣金额2. stats: 分销统计信息，包含：   - totalOrders: 总订单数   - totalAmount: 总金额   - totalCommission: 总佣金   - monthlyStats: 按月统计的订单金额可能的错误：- 如果当前用户不是分销用户，将返回空数据 GET /tourism/client/c/order/distribution/page */
export function distributionOrderPageUsingGetQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.distributionOrderPageUsingGETParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.distributionOrderPageUsingGet(queryKey[1] as typeof options);
    },
    queryKey: ['distributionOrderPageUsingGet', options],
  });
}

/** 用户历史订单 GET /tourism/client/c/order/page */
export function pageUsingGetQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.pageUsingGETParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.pageUsingGet(queryKey[1] as typeof options);
    },
    queryKey: ['pageUsingGet', options],
  });
}

/** 更新订单预约时间 POST /tourism/client/c/order/updateReservationTime */
export function useUpdateReservationTimeUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.updateReservationTimeUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 游客信息 GET /tourism/client/c/order/userinfo */
export function userinfoUsingGetQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.userinfoUsingGETParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.userinfoUsingGet(queryKey[1] as typeof options);
    },
    queryKey: ['userinfoUsingGet', options],
  });
}
